//2009/08/30 22:36:52
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <sstream>
#include <algorithm>

using namespace std;

class SquareOfDigits
{
public:
    int getMax(vector <string> data)
    {
        int ret = 0;
        for (int i=0; i<data.size(); i++)
            for (int j=0; j<data[i].size(); j++)
                for (int k=0; k<min(data[i].size()-j, data.size()-i); k++)
                    if (data[i][j]==data[i+k][j] && data[i][j]==data[i][j+k] && data[i][j]==data[i+k][j+k])
                        ret = max(ret, (k+1)*(k+1));
        return ret;
    }
};
